package util;

import java.io.*;

/**
 * 复制文件
 */
public class CopyFile {
    public static void main(String[] args){
        // 创建操作的文件
        // 源文件
        File file = new File("E:\\Demo1.java.txt");
//        File.separator 分割符
//        复制文件路径
        File copyFile = new File("E:\\javaooGit\\javaooDay21\\copyfile.txt");

        if(!file.exists()){

        }

        if(!copyFile.exists()){
            try {
                copyFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        try(Reader r = new FileReader(file);
            Writer w = new FileWriter(copyFile, true)
        ){
            int a = 0;
            while(a != -1) {
                a = r.read();
                w.write((char) a);
            }
            w.flush();
        }catch (Exception e){

        }
    }
}
